/*******************************************************************************
 * The MOSES project, model based software engineering of networked embedded systems.
 * 
 * Copyright (C) 2010-2013, University of Applied Sciences Wildau,
 * Telematics Research Group, http://www.tm.th-wildau.de/research-group
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 * 
 * Contributors:
 *     University of Applied Sciences Wildau - initial API and implementation
 * 
 * If you are interested in a commercial license please contact us via 
 * e-mail: ralf.vandenhouten@th-wildau.de.
 ******************************************************************************/
package de.thwildau.tm.moses.examples.nmea.data;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import de.thwildau.tm.moses.abnf.io.AbnfCoder;
import de.thwildau.tm.moses.abnf.io.CoreRules;

@Deprecated
public class Rpyl extends Nmea {

    // begin field section
    /** field for rule alphas */
    private String alphas;
    /** field for rule degreesOfRoll */
    private Integer degreesOfRoll;
    /** field for rule degreesOfPitch */
    private Integer degreesOfPitch;
    /** field for rule degreesOfYaw */
    private Integer degreesOfYaw;
    /** field for rule degreesOfSideSlip */
    private Integer degreesOfSideSlip;
    /** field for rule g */
    private Integer g;
    /** field for rule errorCode */
    private Integer errorCode;


    // end field section

    public Rpyl() {
        this.alphas = "RPYL";
    }

    // begin setter getter section
    public void setAlphas(String alphas) {
        this.alphas = alphas;
    }

    public String getAlphas() {
        return this.alphas;
    }

    public Integer getDegreesOfRoll() {
        return degreesOfRoll;
    }

    public void setDegreesOfRoll(Integer degreesOfRoll) {
        this.degreesOfRoll = degreesOfRoll;
    }

    public Integer getDegreesOfPitch() {
        return degreesOfPitch;
    }

    public void setDegreesOfPitch(Integer degreesOfPitch) {
        this.degreesOfPitch = degreesOfPitch;
    }

    public Integer getDegreesOfYaw() {
        return degreesOfYaw;
    }

    public void setDegreesOfYaw(Integer degreesOfYaw) {
        this.degreesOfYaw = degreesOfYaw;
    }

    public Integer getDegreesOfSideSlip() {
        return degreesOfSideSlip;
    }

    public void setDegreesOfSideSlip(Integer degreesOfSideSlip) {
        this.degreesOfSideSlip = degreesOfSideSlip;
    }

    public Integer getG() {
        return g;
    }

    public void setG(Integer g) {
        this.g = g;
    }

    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    @Override
    public void read(DataInput in) throws IOException {
        this.degreesOfRoll = AbnfCoder.decodeUntil(in, ",", Integer.class);
        this.degreesOfPitch = AbnfCoder.decodeUntil(in, ",", Integer.class);
        this.degreesOfYaw = AbnfCoder.decodeUntil(in, ",", Integer.class);
        this.degreesOfSideSlip = AbnfCoder.decodeUntil(in, ",", Integer.class);
        this.g = AbnfCoder.decodeUntil(in, ",", Integer.class);
        this.errorCode = AbnfCoder.decodeUntil(in, ",", Integer.class);
    }

    @Override
    public void write(DataOutput out) throws IOException {
        AbnfCoder.encode(out, "$");
        AbnfCoder.encode(out, alphas);
        AbnfCoder.encode(out, ",");
        AbnfCoder.encode(out, degreesOfRoll);
        AbnfCoder.encode(out, ",");
        AbnfCoder.encode(out, degreesOfPitch);
        AbnfCoder.encode(out, ",");
        AbnfCoder.encode(out, degreesOfYaw);
        AbnfCoder.encode(out, ",");
        AbnfCoder.encode(out, degreesOfSideSlip);
        AbnfCoder.encode(out, ",");
        AbnfCoder.encode(out, g);
        AbnfCoder.encode(out, ",");
        AbnfCoder.encode(out, errorCode);
        AbnfCoder.encode(out, "," + CoreRules.CRLF);
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("$").append(alphas);
        builder.append(",").append(degreesOfRoll);
        builder.append(",").append(degreesOfPitch);
        builder.append(",").append(degreesOfYaw);
        builder.append(",").append(degreesOfSideSlip);
        builder.append(",").append(g);
        builder.append(",").append(errorCode);
        builder.append(",");
        return builder.toString();
    }
}
